package com.itheima.exception;

public class Demo02 {

    public static void main(String[] args) {
        int[] arr={11,22,33,44,55};
        arr=null;
        try{
            printArray(arr);
        }catch (NullPointerException e){
            System.out.println("大哥我们逮住了一个空指针异常");
        }
        System.out.println("哈哈哈 ,我最帅");

    }

    public static void printArray(int[] arr){
        if(arr==null){
            System.out.println("数组为空");
           throw  new NullPointerException();
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }


    }
}
